<template>
    <div>
        <div class="head">
            <span class="iconfont icon-arrow-left-bold" @click="gotoUp"></span>
            <div class="title">设置</div>
        </div>
        <div class="container">
            <div class="group-box">
                <div class="group-item">
                    <div class="name">用户协议</div>
                </div>
                <div class="group-item">
                    <div class="name">隐私协议</div>
                </div>
                <div class="group-item">
                    <div class="name">关于我们</div>
                </div>
            </div>
            <div class="btn" v-if="token" @click="clearToken"><div>安全退出</div></div>
            <div v-else></div>
            <div class="copyright">
                <div class="item">Copyright 2022.</div>
                <div class="item">好学堂 版权所有</div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            token: "",
        };
    },
    methods: {
        gotoUp() {
            this.$router.push({
                path: "/user",
                query: {},
            });
        },
        clearToken() {
            window.localStorage.clear();
            this.$router.go(0);
        },
    },
    created() {
        let token = localStorage.getItem("h5-token");
        if (token) {
            this.token = token;
        }
    },
};
</script>

<style lang="less" scoped>
.head {
    position: fixed;
    top: 0;
    width: 100%;
    height: 50px;
    background-color: #fff;
    z-index: 100;
    padding-left: 15px;
    padding-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f1f2f6;
    span {
        font-size: 19px;
        position: absolute;
        top: 50%;
        margin-top: -10px;
        left: 4%;
    }
    .title {
        flex: 1;
        font-size: 17px;
        font-weight: 500;
        text-align: center;
        color: #333;
        line-height: 22px;
        overflow: hidden;
    }
}

.container {
    padding-top: 50px;
    background: #f6f6f6;
    position: absolute;
    left: 0;
    top: 0;
    overflow-y: scroll;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
    .group-box {
        width: 100%;
        float: left;
        margin: 15px 0;
        background-color: #fff;
        .group-item {
            width: 100%;
            display: flex;
            padding: 8px 15px;
            border-bottom: 1px solid rgba(0, 0, 0, 0.03);
            .name {
                width: 150px;
                line-height: 36px;
                font-size: 15px;
                color: #333;
            }
        }
    }
    .btn {
        div {
            height: 40px;
            line-height: 40px;
            border-radius: 20px;
            text-align: center;
            color: #fff;
            background-color: #3ca7fa;
            font-size: 15px;
        }
        width: 100%;
        padding: 0 15px;
        margin-top: 190px;
    }
    .copyright {
        width: 100%;
        margin-top: 100px;
        text-align: center;
        .item {
            font-size: 10px;
            color: rgba(0, 0, 0, 0.4);
            line-height: 20px;
        }
    }
}
</style>
